<template>
  <!-- 招聘求职 -->
  <div class="content" v-loading="noticeListLoading">
    <div class="recommend-position">
      <!--      <div class="block"></div>-->
      <div class="title">
        已为您找到{{ name }}以下岗位
      </div>
    </div>
    <div class="post-top">
<!--      <div class="post" v-for="(item,index) in noticeList" :key="item.id" @click="skip(item.id)">-->
<!--        <div class="post-top">-->
<!--          <div class="post-title">{{ item.jobTitle }}</div>-->
<!--          <div class="post-pay">{{ item.minSalary }}-{{ item.maxSalary }}元</div>-->
<!--        </div>-->
<!--        <div class="site">{{ item.jobAddress }}</div>-->
<!--        <div class="striping"></div>-->
<!--        <div class="recruiter">-->
<!--&lt;!&ndash;          <img src="../../../public/static/Recruitment/defaultAvatar.jpg" alt="">&ndash;&gt;-->
<!--          <img :src="item.comRecruiters.user.faceUrl" alt="">-->
<!--          <div class="message">{{ item.comRecruiters.comPosition }}  {{ item.comRecruiters.realName }}</div>-->
<!--        </div>-->
<!--      </div>-->
      <div class="position-block">
        <div class="position-item" v-for="(item,index) in noticeList" :key="item.id" @click="skip(item.id)">
          <div class="item-top">
            <div class="post-title">{{item.jobTitle}}</div>
            <div v-if="item.isHeat==1"><img src="@/assets/Recruitment/fair.png" alt="" style="width: 25px;height: 25px;margin: 15px 10px 0 0;"></div>
            <div class="snap" v-if="item.worry==1">急招</div>
          </div>
          <div class="item-middle">
            <div class="post-pay">{{item.minSalary }}-{{item.maxSalary}}元</div>
            <div class="middle-right">
              <div class="message">{{ item.comRecruiters.comPosition }} · {{item.comRecruiters.realName}}</div>
              <img :src="item.comRecruiters.user.faceUrl ? item.comRecruiters.user.faceUrl:'@/static/Recruitment/defaultAvatar.jpg'" alt="">
            </div>
          </div>
          <div class="item-bottom">
            <div class="site"> <div><img src="@/assets/Recruitment/address.png" alt=""></div> {{ item.jobAddress }}</div>
          </div>
        </div>
      </div>
    </div>
    <div v-if="noticeList.length>0 && count>limit"  class="paging">
      <el-pagination
          background
          :page-size="limit"
          layout="prev, pager, next"
          prev-text="上一页"
          next-text="下一页"
          :total="count"
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange"
          :current-page="this.page">
      </el-pagination>
    </div>
  </div>
</template>

<script>
import {
  getPublishListApi,
  getStreetListApi,
  getStreetDataApi
} from '@/api/nearby'
export default {
  name: "Results",
  data(){
    return{
      noticeListLoading:false,
      id: 1,
      name:'',
      page: 1,
      limit: 16,
      count:0,
      noticeList:[
        {
          id:1,
          jobTitle: '',
          minSalary: '',
          maxSalary: '',
          jobAddress: '',
          comRecruiters:{
            comPosition: '',
            realName: '',
            user:{
              faceUrl:''
            }
          },
        }
      ]
    }
  },
  methods:{
    getPublishList() {
      this.noticeListLoading = true
      getPublishListApi({page:this.page,limit:this.limit,streetId:this.streetId}).then((res) => {
        this.noticeList = res.list;
        this.count=res.count
      }).finally(()=>{
        this.noticeListLoading = false
      })
    },
    skip(id){
      this.$router.push({ name: 'Detail',query:{id:id} })
    },
    handleSizeChange(e) {
      this.limit = e
      this.getPublishList()
    },
    handleCurrentChange(e) {
      this.page = e
      sessionStorage.setItem('currentPage',this.page)
      sessionStorage.setItem('currentPage1',this.streetId)
      this.getPublishList()
    },
  },
  created() {
    //document.addEventListener('scroll',this.handelscroll)
    let currentPage=sessionStorage.getItem('currentPage')
    if(currentPage!=null){
      this.page = Number(currentPage)
    }
    let currentPage1=sessionStorage.getItem('currentPage1')
    if(currentPage1!=null){
      this.streetId = Number(currentPage1)
    }
  },
  updated() {
    let scrollTop = sessionStorage.getItem('scrollTop')
    window.scrollTo({
      top:scrollTop,
      behavior: 'instant'
    })
    sessionStorage.setItem('scrollTop',0);
  },
  mounted() {
    this.utils.createParams(this,this.$route.params);
    // this.id=this.$route.params.id
    // this.name=this.$route.params.name
    this.getPublishList()
  }
}
</script>

<style lang="scss" scoped>
.content{
  .position-block{
    width: 800px;
    margin: 0 auto;
    display: flex;
    flex-wrap: wrap;
    .position-item{
      background-color: #fff;
      border-radius: 15px;
      margin:10px 10px;
      width: calc((100% - 45px) / 2);
      height: 145px;
      padding: 10px 20px;
      box-sizing: border-box;
      .item-top{
        width: 340px;
        display: flex;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        .post-title{
          margin: 15px 10px 0 0;
          font-size: 15px;
          font-weight: 900;
          white-space: nowrap;
          overflow: hidden;
          text-overflow: ellipsis;
        }
        .snap{
          width: 47px;
          height: 23px;
          border: 1px solid #C0959A;
          border-radius: 4px;
          font-size: 15px;
          color: #D94349;
          text-align: center;
          margin-top: 15px;
        }
      }
      .item-middle{
        width: 340px;
        display: flex;
        justify-content: space-between;
        height: 40px;
        .post-pay{
          margin-top: 10px;
          color: #5493F3;
          font-size: 15px;
        }
        .middle-right{
          display: flex;
          font-size: 15px;
          align-items: center;
          img{
            width: 35px;
            height: 35px;
            margin: 0 0 0 15px;
            border-radius: 30px;
          }
        }
      }
      .item-bottom{
        width: 340px;
        .site{
          display: flex;
          margin-top: 5px;
          color: #8E8E8E;
          font-size: 15px;
          .siteClass{
            height: 40px;
            overflow:hidden;
            text-overflow:ellipsis;
            display:-webkit-box;
            -webkit-box-orient:vertical;
            -webkit-line-clamp:2;
          }
          img{
            width: 15px;
            height: 15px;
            margin-top: 3px;
          }
        }
      }

    }
  }
  ::v-deep{
    .btn-prev{
      //min-width: 50px;
      span{
        display: block;
        min-width: 70px;
      }
    }
    .btn-next{
      span{
        display: block;
        min-width: 70px;
      }
    }
  }
  .recommend-position{
    width: 800px;
    height: 70px;
    background-color: #fff;
    color: #498CF3;
    padding: 0 30px;
    border-radius: 20px;
    margin: 35px auto 30px;
    display: flex;
    align-items: center;
    box-sizing: border-box;
    //text-align: center;
    justify-content: center;
    //padding: 0 1;
    //.block{
    //  background-color: #498CF3;
    //  width: 10px;
    //  height: 30px;
    //  border-radius: 15px;
    //  margin-right: 15px;
    //}
    .title{
      text-align: center;
      font-size: 24px;
      font-weight: 900;
      padding-bottom: 3px;
    }
  }
  .post-top{
    width: 800px;
    margin: 0 auto;
    display: flex;
    flex-wrap: wrap;
    //justify-content: space-between;
    .post{
      padding: 20px 18px;
      background-color: #fff;
      border-radius: 15px;
      margin-top: 15px;
      width: calc((100% - 30px) /3);
      margin-right: 15px;
      height: 235px;
      .post-top{
        box-sizing: border-box;
        display: flex;
        justify-content: space-between;
        .post-title{
          width: 260px;
          font-size: 26px;
          overflow: hidden;
          text-overflow: ellipsis;
          white-space: nowrap;
        }
        .post-pay{
          font-size: 26px;
          color: #5493F3;
        }
      }
      .striping{
        margin-top: 20px;

        width: 100%;
        height: 2px;
        background-color: #D8D8D8;
      }
      .site{
        font-size: 20px;
        margin-top: 20px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
      }
      .recruiter{
        display: flex;
        align-items: center;
        margin-top: 20px;
        img{
          width: 52px;
          height: 52px;
          border-radius: 30px;
          margin-right: 15px;
        }
        .message{

        }
      }
    }
    .post:nth-child(3n){
      margin-right: 0;
    }
  }
  .paging{
    display: flex;
    flex-direction: row;
    justify-content: center;
    align-items: center;
    margin-top: 20px;
    .el-pagination is-background{
      display: flex;
      text-decoration: none;
    }
  }
}
</style>

